#include <iostream>
using namespace std;
class FlyBehavior{
	public:
		virtual void fly() = 0;
};
class QuackBehavior{
	public:
		virtual void quack() = 0;
};

class FlyWithWings:public FlyBehavior{
	public:
		virtual void fly() {cout << "fly with wings" << endl;}
};
class FlyNoWay:public FlyBehavior{
	public:
		virtual void fly(){cout << "can not fly" << endl;}
};
class Quack:public QuackBehavior{
	public:
		virtual void quack(){cout << " quack " << endl;}
};
class Squeak:public QuackBehavior{
	public:
		virtual void quack(){cout << " zz quack " << endl;}
};
class MuteQuack:public QuackBehavior{
	public:
		virtual void quack(){cout << " Mutes quack " << endl;}
};

class Duck{
	public:
		virtual void display() = 0;
		virtual void swin() {cout << "swim" << endl;}
		void performFly(){
			flyBehavior->fly();
		}
		void performQuack(){
			quackBehavior->quack();
		}
		FlyBehavior *flyBehavior;
		QuackBehavior *quackBehavior;
};

class MallardDuck:public Duck{
	public:
		MallardDuck(){
			flyBehavior = new FlyWithWings();
			quackBehavior = new Quack();
		}
		virtual void display() {cout << "MallardDuck" << endl;}
	private:
};

class RedheadDuck:public Duck{
	public:
		RedheadDuck(){
			flyBehavior = new FlyWithWings();
			quackBehavior = new Quack();
		}		
		virtual void display(){cout << "show RedheadDuck" <<endl;}
};

class RubberDuck:public Duck{
	public:
		RubberDuck(){
			flyBehavior = new FlyNoWay();
			quackBehavior = new Squeak();
		}		
	virtual void display(){cout << "show RubberDuck" <<endl;}
};

int main(){
	Duck *duck = new RubberDuck();
	duck->performFly();
	duck->performQuack();
	duck->display();
	return 0;
}